<template>
  <div class="invite-wrap">
    <div class="pic-box">
      <img src="./invite_title.png" class="pic" onclick="return false"/>
    </div>

    <div class="invite-box">
      <vue-qr :logoSrc="config.logo" :text="config.value"></vue-qr>
    </div>

    <div class="title-box">扫描二维码，注册/入职蓝聘</div>
  </div>
</template>

<script>
  import VueQr from 'vue-qr';
  import {getUserCookie, getSessionStore} from "../../common/js/util";

  export default {
    data() {
      return {
        config: {
          value: '',
          logo: require('./avatar.png')
        },
        identity: ""
      }
    },
    mounted() {
      this.$vux.loading.show({
        text: '加载中',
      });
      let avatar = sessionStorage.getItem("avatar");
      if (avatar != null && avatar != "" && avatar != undefined) {
        this.config.logo = sessionStorage.getItem("avatar");
      }

      //TODO 线上邀请好友跳转路径-正式服
      let url = window.location.protocol + "//domin.lanpin123.com:1972/login";

      // let url = window.location.protocol + "//192.168.0.152:8090/login";
      let code = getUserCookie();
      if (code.identity) {
        this.identity = code.identity;
      } else {
        this.identity = getSessionStore("identity");
      }

      this.config.value = url + "?identity=" + this.identity;
      this.$vux.loading.hide();
    },
    components: {
      VueQr
    }
  }
</script>

<style lang="stylus" scoped>
  @import "../../common/stylus/mixin.styl"

  .invite-wrap
    wh(100%, 100%)
    bg-image("./banner.png", 100%, 100%)
    overflow: hidden
    .pic-box
      margin: 0 auto
      margin-top: 1.373rem
      margin-bottom: 1.773rem
      wh(6.827rem, 1.04rem)
      .pic
        wh(100%, 100%)
    .invite-box
      margin: 0 auto
      wh(6.4rem, 6.453rem)
      box-shadow: 0rem 0rem 1.2rem 0rem rgba(21, 121, 198, 0.19)
    .title-box
      margin-top: 1.067rem
      text-align: center
      size-color(0.4rem, rgba(255, 255, 255, 1))
</style>
